home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / falcon / wd2d_pro / sources / wd2d_pro.txt < prev   
Text File  |  1995-04-27  |  20KB  |  459 lines

  1. Wax Direct To Disk Player
  2. Professional Edition
  3.  
  4.  
  5.  
  6. This software was started in June/July 1993 just when I bought my Falcon 030.
  7. I started it with Gen at the time, and continued it alone.
  8. It was working perfectly all right as TOS, so when Gen & I did our Fabulous Macros 
  9. Release 3 ... (just like an object-oriented language but in assembler, we only code in 
  10. assembler on the Falcon 030 because some other people force us to code in 
  11. C/Shell/Fortran on other shitty machines (hey ! ya know the one starting with P and 
  12. ending with C)) ... I decided to convert it into GEM environment (with multi-tos 
  13. possibilities) and finally I added lots a features (concerning compression/decompression) 
  14. so it has become what it is !
  15.  
  16. This program is written in what I call "Good assembler" it means no supervisor rout, only 
  17. Trap calls. The only possible incompatibility with the future Falcon 040 is the Timer-A 
  18. interrupt routine which uses the hard addresses of the DMA sound port. (Start/End 
  19. replay Address)
  20. I did it because using the xbios trap in interruption did bring me some bombs sometimes, 
  21. very strange by the way ...
  22.  
  23.     With this fabulous software, you can play any sample which is 16 bits (mono or 
  24. stereo) at any conventional frequency. Even with external sync if you can connect one on 
  25. your DSP port !
  26.  
  27.     You can improve your comfort of  listening in three ways :
  28. - first : getting the fabulous selectrix which permits you to play several samples or 
  29. Play-List continuously.
  30. - second : making some .WAX files (an example is provided below) which should be put 
  31. in the same directory as the track and which permit to define the frequency, header 
  32. length, and format of your track (they will be loaded if they exist).
  33. - third : making some .LT files (an example is provided below) which permits you to 
  34. prepare a list of the tracks that you want to hear (just like a disk-jockey) even if they are 
  35. on different partitions.
  36.  
  37.  
  38.  
  39.                         Enjoy the quality.
  40.                         WAX, December 23th 1994.
  41.  
  42.     Explanations about the .WAX files :
  43. You can store some small files with your tracks (same directory, same name but .WAX as 
  44. extension) which give the infos about the file type. Useful if they were recorded with D2D 
  45. Edit (header included) or Falc D2D (no frequency info).
  46. Those files will allow you to play multiple files (if you have selectrix) provided you put 
  47. the good infos in them and that you turn off the 'Loop' option.
  48. Warning : they must not exceed 256 bytes : only the first 256 bytes will be loaded. (they 
  49. will not, unless you put some very big comments (like me))
  50.  
  51. Here is an implementation example :
  52.     dir f:\tracks\
  53.  
  54.         SUSSUDIO.TRK    16458400 bytes.    (16 bit track)
  55.         SUSSUDIO.WAX    213 bytes.        (text file)
  56.  
  57.         The .Wax files have this kind of format (edit them with any text editor) :
  58.  
  59.         ; put a dot : '.' after the end of each parameter.
  60.  
  61. head=16.    ; can be anything if form=dvsm.
  62.         ; Put 16 for a 16-bit winrec DVSM unpacked file renamed as .TRK
  63.         ; Put the good value for a D2D Edit file (I Don't know which one, I don't 
  64. use it)
  65.  
  66. freq=49.    ; can be 8,10,12,16,20,25,33,49.
  67.  
  68. form=16bs.    ; can be 16bs (16 bit stereo) or 16bm (16 bit mono)
  69.         ; or dvsm (I can read Winrec samples but he cannot read mine : 2 bombs)
  70.         ; automatic mono/stereo detect for dvs.
  71.  
  72. ster=YES.    ; can be YES. or NO. tells that this file should be replayed using a
  73.         ; pseudo-stereo method if it is mono.
  74.  
  75. dlay=25.    ; see above : it is the delay in milliseconds that should be applied to slide
  76.         ; the left and right channels.
  77.  
  78.  
  79.     Explanations about the .LT files :
  80.  
  81. You can create some small files (List of Tracks) which, once loaded, allow you to play 
  82. tracks which are on different partitions, in the order that you want. (not a type classified 
  83. one like selectrix)
  84.  
  85. Here is an implementation example (don't put any tab or comment):
  86.     cat f:\tracks\list.lt
  87.  
  88.         e:\wonder.trk
  89.         f:\samples\maximum.dvs
  90.  
  91.     About using the Wax Player as a program :
  92. You shall declare it as an application for all .TRK, .DVS and .LT files.
  93.  
  94.     About using the Wax Player in accessory :
  95. You can rename the program WD2D_PRO.APP to WD2D_PRO.ACC and listen to 
  96. tracks while working under mono-task environment.
  97. Every ACC-CLOSE event will stop the music (so no bug when changing resolution). If  
  98. you want to stop the currently playing track, then call the accessory again and press 
  99. 'Cancel' on file-selector.
  100. Some bombs appear when assembling under Devpac while playing a track, I still wonder 
  101. why (I mean : is it my fault ?)
  102.  
  103.     You can also send him orders using the GEM messages (message number is 224) 
  104. and send him three sorts of ASCII messages (look at the source CALL_WAX.S):
  105. - tell him to play a file : "play=g:\samples\track.trk"
  106. - tell him to stop playing : "stop"
  107. - tell him to convert a file : like this
  108.     "conv=1,file1.trk,file2.trk,"            ; stéréo -> mono
  109.     "conv=2,file1.trk,file2.trk,file3.trk,"    ; stéréo -> R & L
  110.     "conv=3,file1.trk,file2.trk,"            ; mono -> stéréo
  111.     "conv=4,table.tab,"                ; choose compression table
  112.     "conv=5,file1.trk,file2.dvs,"        ; TRK stéréo -> DVS
  113.     "conv=6,file1.trk,file2.dvs,"        ; TRK mono -> DVS
  114.     "conv=7,file1.dvs,file2.trk,"        ; DVS -> TRK
  115.  
  116.     Explanations about the menus :
  117.  
  118.  Files :
  119.  
  120.     Load :
  121.     choose your track(s) to be played. If you have selectrix then you can play several 
  122. tracks continuously. Don't forget to disable the Loop option in this case.
  123.     If your track does not play then it means that another program uses the Sound 
  124. Semaphore, so stop it before !
  125.     If you had selected several tracks and you had stopped one, you will not have the 
  126. file selector(except if it was the last one) and the next file will be played.
  127.  
  128.     Get info on file :
  129.     Allows you to have information (title, author, pack method, frequency, time of 
  130. replay) on a .DVS file or, if a .LT file is selected, the time of replay for all files (*.DVS) 
  131. will be displayed.
  132.  
  133.     Loop :
  134.     replays when you reach the end of the track. If a list of tracks is selected : uncheck 
  135. it !
  136.  
  137.     Stop :
  138.     lets you stop the replay without exiting and liberates the sound Semaphore.
  139.  
  140.  
  141.  Frequency :
  142.  
  143.     You can choose your frequency 8 ... 49.
  144.     It will be set immediately if a sample is playing, or only at loading initialization if 
  145. none is played.
  146.     External or Internal will allow you to choose the synchronization mode.
  147.  
  148.  
  149.  Method :
  150.  
  151.     Method 1 :
  152.     natural 16 bit stereo sound (natural for a Falcon of course)
  153.  
  154.     Method 2 :
  155.     allows you to play a mono sample (left=right) very interesting compared to stereo 
  156. 16 bit : 50 % of room for no difference on tracks which do not use fabulous stereo effects.
  157.  
  158.     Method 3 :
  159.     the most interesting, allows you to replay a track which has been compressed 
  160. under DVS format : 50 % for same quality in 16 bits. (better though if packed with Wax 
  161. D2D Player than Winrec 1.371 : longer time but finer compression table)
  162.  
  163.     Replay mono files in pseudo-stereo :
  164.     if this menu is checked (or if ster=YES. in you .WAX file) then mono tracks will be 
  165. replayed sliding the left and right channels of some milli-seconds (0 to 99). The value is 
  166. set by the next option (see below)
  167.  
  168.     Adjust pseudo-stereo delay :
  169.     this is the value for pseudo-stereo effects in milliseconds, it can range from -99 to 
  170. 99 including 0 : mono replay. The difference between a value of -45 and a value of +45 
  171. will be which channel will be 'in advance' : left or right ?
  172.     You can try values during the replay, and it's very interesting to do it to see how 
  173. the sounds starts by getting a sort of 'volume in space' to reach an echo effect for large 
  174. values.
  175.     You will also notice that it is TOTALLY DIFFERENT whether you are using 
  176. headphones or amplificated speakers which are seperated by 5 meters (logical when you 
  177. get to think about it) ... You can make some very impressive effects if the value is adapted 
  178. to the layout of your room ...
  179.  
  180.  
  181.  Conversion :
  182.  
  183.     Left/Right => Mono :
  184.     Converts your track in mono (50% room) just doing (Channel L+ Channel R)/2.
  185.  
  186.     Left/Right => Left + Right :
  187.     You take a stereo file and you create two mono files containing the left and right 
  188. sounds (useful to convert in mono a file which has a much better channel than the other)
  189.  
  190.     Mono => Left/Right :
  191.     Just the opposite : puts the a mono channel on left & right (you lose 100 % of 
  192. room). This can be useful if your favorite sample editor processes only stereo sounds. 
  193. (Winrec for instance)
  194.  
  195.     Choose compression table :
  196.     You will load the table that will be used for compression (see next menus) your 
  197. table must have $8000 as first value(0) , $0000 for value 128 and $7FFF for value 255. 
  198. Its length must be of 256*2 bytes.
  199.  
  200.     Some pre-calculated tables are given :
  201.     - DVSM.TAB : the table used by Winrec.
  202.     - DVSW1.TAB : same as DVSM but with never twice the same value (it's no use 
  203. having the same value twice, unless it's quicker to pack/unpack (it's the case for 
  204. Winrec))
  205.     - DVSW2.TAB : a table calculated to keep a theoretical constant distortion rate 
  206. (see menu below called Calculate distortion) of 4.5%
  207.     - DVSW3.TAB : a table calculated for a 3.6 % but strangely depending on the 
  208. tracks does sometimes better, and sometimes worse than the previous one.
  209.     - in fact DVSW2 = DVSW3 please, do analyze sample before.
  210.  
  211.     Stereo track => DVS :
  212.     Mono track => DVS :
  213.     DVS => original Track :
  214.     You can now pack/depack your favorite tracks using the Wax packer, to stop 
  215. conversion : press the left and right shift simultaneously.
  216.     The table is saved in the compressed file and used for replay, assuming full 
  217. compatibility if you were to create your custom compression table (optimizing your own 
  218. criteria).
  219.     The frequency saved in the file header is the one selected in the menu Frequency.
  220.  
  221.  
  222.  Special : (available only for 6888x owners)
  223.  
  224.     Analyze stereo track :
  225.     Lets you have an idea about the deltas (average, variance max and min) which is 
  226. very useful when you want to create your own compression table which will be optimum 
  227. for your own specific sample.
  228.  
  229.     Calculate distortion :
  230.     Just imagine that you have an original track (.TRK) (recorded with Falc_D2D) that 
  231. you compress it with different methods DVSM, DVSW1(table 1) & DVSW2(table 2) and 
  232. that you decompress them to compare them with the original to calculate the difference 
  233. (because of course your ears can't hear anything). It is what this program will do. You 
  234. must create some .WAX files if you've got some original DVSM files to set the header to 
  235. 16 (otherwise you'll get some amazing results)
  236.  
  237.     The calculation is very simple :
  238.     you read a 16 bits value in the first sample : V1, you read another in the second 
  239. file : V2, you calculate (V1-V2)/V1 you do it many times (128*1024/2) and you print the 
  240. average result multiplied by 1000.
  241.     You'll get what I call a "Distortion Rate".
  242.  
  243.     Just for your general knowledge (and for my pride) :
  244.         DVSM recorded by Winrec : 8-9 %
  245.         DVSM converted by the Wax D2D Pro (optimum) : 3-4 %
  246.  
  247.  
  248.  
  249. That is all for the use of the Wax Direct to Disk Player,
  250. Have Fun !
  251.  
  252. The DVS file format
  253.  
  254.  
  255. header:    6 bytes    DVSM\0\0
  256. length:    1 word    distance of the sound data from the start of the file.
  257. freq:        1 word     0-7 : allowed CODEC frequencies (0: 8kHz ...  7: 49kHz)
  258. pack:        1 byte        0=not packed,2=DVS pack,4=voice pack
  259. mode:        1 byte        0=stéréo 8bit, 1=stéréo 16bit, 2=mono 8bit, 3=mono 16bit
  260. block_length:    1 long        block length : for mono files 8*7*6*5*4*2+2
  261.  
  262.         16 bytes
  263.  
  264.     followed by optional cookies (can be read or skipped)
  265.  
  266. cookie_identify:    1 long
  267. cookie_length:    1 word    should be 6 + length of the following data
  268. cookie_data:        x bytes
  269.  
  270.     list of the so far recognized cookies :
  271.  
  272. cookie        Lenght of the data    Usage
  273. -------------------------------------------------------------------------------------------------------------------------
  274. 'LPKC'        1 word        length of pack code in bits (8 -> 1)
  275.  
  276. 'TITL'        26 bytes        Title of the song
  277.  
  278. 'AUTH'    26 bytes        Author of the song
  279.  
  280. 'CLCK'        1 word         0: intern clock, 1: extern CD, 2: extern DAT
  281.  
  282. 'PEAK'        4 byte            one word for the left and right channel 
  283. containing the
  284.                     highest sample value
  285.  
  286. 'DSPE'        x bytes        DSP program (soundeffect !!) in binary format
  287.  
  288. 'PARA'        x bytes        x parameters for the sound effect. NOT before 
  289. the
  290.                     'DSPE' block!
  291.  
  292. 'PACK'        512 or 16 bytes    Deltapack table for the distance values. Used 
  293. instead of
  294.                     the standard table.
  295.  
  296. 'INFO'        x bytes        info text (e.g. full title)
  297.  
  298.  
  299. Not use in WinRec (by now)
  300. 'KARA'        x Bytes        karaoke text (see below)
  301.  
  302. The maximal header length (all blocks together) is limited to 65535 Bytes.
  303. Every programm should parse the blocks, and decide to use them or not.
  304.  
  305. karaoke text format
  306. ---------------------------
  307.     long cookie='KARA'
  308.     int len
  309.     int textlen
  310.  
  311. followed by the text ('textlen' bytes) in standard ASCII format. After this the extension 
  312. included a measure table, with a long word (4 byte) for every word in the text. The long 
  313. word contains the time distance to the next word in 1/sampling frequency
  314.  
  315. Additional information
  316.  
  317.  
  318. How to create a constant distortion rate compression table :
  319.  
  320.     Just imagine you have a value V (a delta of course) to compress, you search in 
  321. your compression table and you find that the inferior value for your delta is Vi and that 
  322. the superior value is Vs. The biggest error in percentage would be if you had to encode 
  323. (Vi+Vs)/2. Let's assume that it's the case. Then you set your relative-error (distortion 
  324. rate) to T.
  325.  
  326.     You'll get the following two equations :
  327.             T=(Vs-V)/V
  328.             T=(V-Vi)/V
  329.  
  330.     Eliminating V, you get the following : Vs=Vi*(1+T)/(1-T)=Vi*alpha
  331.  
  332. If you start at the 1 value then the second is given by the formula:
  333. 1*alpha then 1*alpha^2...
  334.  
  335.     If you assume that the maximum delta that can appear is 32767 (which is very 
  336. close to reality), then you have a relation between the number of bits for your table (8 
  337. bits <=> 256 values) and the distortion rate. You can even think about a 7 bit 
  338. pack/unpack. (68030 or DSP only, if you have real time willings)
  339.  
  340. 32767=1*((1+T)/(1-T))^(2^(n-1)-1)=alpha^127 for n=8.
  341.  
  342. 8 bit table gives 4.12 % distortion
  343. 7bit : 8.36 %
  344. 6 bit : 17.15 %
  345. 5 bit : 35 %
  346. 4 bit : 70 %.
  347.  
  348.     Creating your table this way (floating calculus), you will see that some consecutive 
  349. values are the same (at the beginning in fact), you can do a test and so optimize again 
  350. your table this way :
  351.  
  352.         value=1
  353.         repeat 2^(n-1)-1 times
  354.         store value;
  355.         next=int(value*alpha)
  356.         if next=value then next=value+1
  357.         value=next
  358.         loop
  359.  
  360.     There are two ways :
  361.  
  362.     - First : you calculate your tables making T smaller and smaller each time, until 
  363. you reach 32767 for last value. Then you calculate your final table with the T that you 
  364. found.
  365.     - Second : you don't touch T and then you'll get a greater dynamic (your 
  366. maximum delta will not be 32767 but bigger) but it's less interesting and the Wax Player 
  367. won't accept your table because the last value is not 32767.
  368.  
  369.     Your final table must be symmetrical in the way that 0 is in the middle of the table 
  370. (128th value), $7FFF is the last one (255th) and -32768 the first value(offset 0), all your 
  371. values must be classified in the growing order and though two consecutive values should 
  372. not be equal, you can do it anyway.
  373.  
  374.     You can do like me : you calculate the positive values (algorithm is given) you 
  375. then inverse (-) them for the negative range, the final result should look like this :
  376.  
  377.     -32768 -32767 ........... -4 -3 -2 -1 0 1 2 3 4 ...... 32767   : values
  378.         0          1                                128                      255    : index
  379.  
  380. Another approach : statistical compression table :
  381.  
  382.     You can build your compression table in a second way. You scan your sample and 
  383. store the deltas, then you calculate the average delta, and the variance. (this corresponds 
  384. to the menu : Analyze stereo track)
  385.  
  386.     And then, assuming it's a Gaussian repartition you make your values so that they 
  387. are centered exponentially around the average delta. Taking average +/- variance should 
  388. bring you 66 % of values, +/- 2*variance : 95 % , etc ...
  389.      I have tried, and it seems that the repartition is not quite Gaussian.
  390.     You must not forget the values -1, 0 and 1 in your table, otherwise it may happen 
  391. that a follow-trajectory and a static error appears.
  392.  
  393.     Another way, that would lead to another format (why not?) would be to analyze, 
  394. let's say 128K of sample and to build a specific table well adapted to it, and then to 
  395. analyze another 128K and to build a second table ... and so on (very little room lost 
  396. because 512 << 128*1024).
  397.  
  398.     Even better, you could think about having deferent bit-pack-codes in the same file 
  399. (8 bit pack ... then 7 bit then 9 bit ... etc ... with headers giving you the pack size.
  400.  
  401. Always remember those basic rules to record a sound (whichever) :
  402.  
  403.     When you are talking about recording sounds, there are four parameters that must 
  404. be taken into account :
  405.  
  406.     - the sampling frequency.
  407.     - the time of recording.
  408.     - the signal/noise rate.
  409.     - the maximum signal amplitude.
  410.  
  411.  
  412.     Sampling frequency :
  413.     you should theoretically take at least twice the maximum harmonic frequency of 
  414. your signal. In fact an average 10 times is more realistic for your ears. For simple human 
  415. voice on the contrary, 8 KHz is far enough (humans hardly go over 1 KHz). Please notice 
  416. (and try it if you don't believe me) that your ears don't make the difference between 33 
  417. KHz and 49 KHz for 99,9 % of tracks, whereas it is nearly twice the room in terms of 
  418. bytes.. Think about it ...
  419.  
  420.     Time of recording :
  421.     depending only on you and on your hard disk ! Just know that the room taken will 
  422. be : freq*2*2 bytes*seconds_of_record for 16 bit stereo tracks.
  423.  
  424.     The signal/noise rate :
  425.      Not depending on you, it comes directly from the source of the sound. If it is a 
  426. DDD laser disk : 96 DB, if it is a ADD or AAD then 70 DB, finally if the source is a cassette 
  427. then it goes from 48 DB (Dolby A) to 68 DB (Dolby C).
  428.  
  429.     Know for yourself that a sound recorded in 8 bit has a signal/noise rate of 
  430. 20*log(2^8)=48 DB and in 16 bit mode : 96 DB.
  431.  
  432.     Direct deduction : IT IS TOTALLY USELESS (ROOM WASTING) TO RECORD IN 
  433. 16-BIT MODE A SOUND COMING FROM A DOLBY-A CASSETTE.
  434.  
  435.  
  436.     The maximum signal amplitude :
  437.     Depending on you totally, so you have to put you Falcon's input gain at its 
  438. maximum and then to regulate your source output level so that your sound reaches just 
  439. the limits of saturation. The principle is to use your falcon input attenuation at its 
  440. minimum level so that your source amplifies the least, because additional source istortion 
  441. is directly depending on the output level. (Whatever the analogic source)
  442.     Beware of one single thing : it may sometimes be more intelligent to have some 
  443. seconds of saturation in a 3 minute long track but an improved global signal/noise, than 
  444. to have no saturation at all but a low average sound level. Don't forget that you 
  445. sometimes don't hear any saturation at all even if there is one, and that anyway, the Wax 
  446. D2D Player has no bug when packing those sorts of tracks.
  447.  
  448.  
  449.  
  450. Global conclusion :
  451.  
  452.     The Wax compression is better (no cheat) it has the advantage of having no 
  453. problem with saturation (not like Winrec, hum) but it cannot be done in real time 
  454. because lots a comparisons in .L are needed. On the other hand, once packed it is strictly 
  455. the same principle and decompression algorithm (in assembler though) as Winrec (I 
  456. copied his very clever idea). Real time compression could be done with 68040 or DSP but 
  457. it does not interest me for the time being. Finally, as my files are not made of blocks, no 
  458. easy copy/paste or seek can be done, but so easy to program !
  459.